Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: QuickTime

Previous | Overview | Contents | Next |

Working With Track Time

The Movie Toolbox provides several functions that allow your application to determine and establish a track's time parameters. A track uses the time base of the movie that contains the track; therefore there are no functions that work with a track's time base or time scale. However, you can determine a track's duration and its offset from the start of a movie.

All of the tracks in a movie use the movie's time coordinate system. That is, the movie's time scale defines the basic time unit for each of the movie's tracks. Each track begins at the beginning of the movie, but the track's data might not begin until some time value other than 0. This intervening time is represented by blank space--in an audio track the blank space translates to silence; in a video track the blank space generates no visual image. This blank space is the track offset. Each track has its own duration. This duration need not correspond to the duration of the movie. A movie duration always equals the maximum track duration. See Figure 6 for a visual representation of track duration and track offset.

You can use the GetTrackDuration function to determine a track's duration.

The SetTrackOffset and GetTrackOffset functions enable you to work with a track's offset from the start of the movie that contains it.

The TrackTimeToMediaTime function lets you translate a track's time to the corresponding time value of a media in the track.

GetTrackDuration

The GetTrackDuration function returns the duration of a track. The duration corresponds to the ending time of the track in the movie's time coordinate system (remember that all tracks start at movie time 0).

pascal TimeValue GetTrackDuration (Track theTrack);
theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

DESCRIPTION

The GetTrackDuration function returns a time value. This time value indicates the track's duration, and it is expressed in the time scale of the movie that contains the track.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

SetTrackOffset

The SetTrackOffset function modifies the duration of the empty space that lies at the beginning of the track, thus changing the duration of the entire track. You specify this time offset as a time value in the movie's time scale. See Figure 6 for an illustration of a track offset in a movie.

pascal void SetTrackOffset (Track theTrack,
                                          TimeValue movieOffsetTime);
theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

movieOffsetTime
Specifies the track's offset from the start of the movie, and must be expressed in the time scale of the movie that contains the track.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

SEE ALSO

You can determine a track's time offset by calling the GetTrackOffset function, which is described in the next section.

GetTrackOffset

The GetTrackOffset function allows your application to determine the time difference between the start of a track and the start of the movie that contains the track.

pascal TimeValue GetTrackOffset (Track theTrack);
theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

DESCRIPTION

The GetTrackOffset function returns a time value. This time value indicates the track's offset from the start of the movie, and it is expressed in the time scale of the movie that contains the track.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

SEE ALSO

You can set a track's offset by calling the SetTrackOffset function, which is described in the previous section.

TrackTimeToMediaTime

The TrackTimeToMediaTime function allows your application to convert a track's time value to a time value that is appropriate to the track's media using the track's edit list. You specify the track's time in the movie's time coordinate system.

pascal TimeValue TrackTimeToMediaTime (TimeValue value,
                                         Track theTrack);
value
Specifies the track's time value; must be expressed in the time scale of the movie that contains the track.

theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

DESCRIPTION

The Movie Toolbox returns a value that is in the media's time coordinate system.

You can use the TrackTimeToMediaTime function to determine whether a specified track edit is empty. If the track time corresponds to empty space, this function returns a value of -1.

The TrackTimeToMediaTime function maps the track time through the track's edit list to come up with the media time. This time value contains the track's time value according to the media's time coordinate system. If the time you specified lies outside of the movie's active segment or corresponds to empty space in the track, the TrackTimeToMediaTime function returns a value of -1.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid


© 1999 Apple Computer, Inc.

Previous | Overview | Contents | Next